import chardet


def detect_encoding(path):
    with open(path, 'rb') as f:
        det = chardet.detect(f.read())
    return det


if '__main__' == __name__:

    paths = [
        r'D:\_dell7590_root\sync\1_usb\M2\main\mat\txt\utf8_and_gbk\gbk.txt',
        r'D:\_dell7590_root\sync\1_usb\M2\main\mat\txt\utf8_and_gbk\utf16be.txt',
        r'D:\_dell7590_root\sync\1_usb\M2\main\mat\txt\utf8_and_gbk\utf16le.txt',
        r'D:\_dell7590_root\sync\1_usb\M2\main\mat\txt\utf8_and_gbk\utf8_no_bom.txt',
        r'D:\_dell7590_root\sync\1_usb\M2\main\mat\txt\utf8_and_gbk\utf8_with_bom.txt',
    ]

    encodings = []
    for path in paths:
        enc = detect_encoding(path)
        encodings.append(enc)

    print(list(zip(paths, encodings)))
